package HLLib.base;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLLibObject;

public class HLRandom extends HLLibObject {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_BASE, HLClassManager_H.LIB_CLASS_BASE_Random);
    }

    private int seed = (int) System.currentTimeMillis();

    public void SetSeed(int seed) {
        this.seed = seed;
    }

    public int Next() {
        seed = 214013 * seed + 2531011;
        return seed ^ seed >> 15;
    }

    public int NextEnd(int end) {
        return (Next() & 0x7fffffff) % (end + 1);
    }

    public int NextMax(int max) {
        return (Next() & 0x7fffffff) % (max);
    }

    public int NextMinMax(int min, int max) {
        return min + (Next() & 0x7fffffff) % (max - min);
    }

    public int NextStartEnd(int start, int end) {
        return start + (Next() & 0x7fffffff) % (end + 1 - start);
    }
}
